﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using NHibernate;
using NHibernateLibrary.Entities;
using NHibernateLibrary.Helper;
using GatorGradNet.DataAccessLayer;
using GatorGradNet.BusinessLayer;

public partial class PrevWork : System.Web.UI.Page
{
    string prevEdu, username;
    protected void Page_Load(object sender, EventArgs e)
    {
        prevEdu = Session["PrevWork"].ToString();
        username = Session["Username"].ToString();

        generateCards(prevEdu, username);
    }
    public void generateCards(string prevEdu, string username)
    {
        
        IList<ProfileUser> eduUsers = GatorGradNet.BusinessLayer.UserManagement.Instance().GetGatorsByPreviousEmployment(prevEdu);
        int i = 0;
        string html;
        foreach (ProfileUser pr in eduUsers)
        {
            if (pr.Username.Equals(username))
                continue;

            html = createCard(pr.FirstName + " " + pr.LastName, pr.Branch, pr.Email,pr.Gender);
            if (i % 6 == 0)
            {
                html = "<div class='row-fluid'>" + html;
            }
            else if (((i + 1) % 6 == 0) || (((i + 1) == eduUsers.Count) && (((i + 1) % 6) != 0)))
            {
                html = html + "</div>";
            }
            Literal user = new Literal();
            user.Text = html;
            this.group.Controls.Add(user);
            i++;
        }
    }
    public String createCard(string name, string branch, string email)
    {
        string html = "<div class='card people'><div class='card-top green'><img src='images/silhouette_homer.png' alt='' /></div><div class='card-info'><a class='title' href='#'>" + name + "</a><div class='desc'>" + branch + "<br />" + email + "</div></div><div class='card-bottom'><a id=" + email + " class='btn btn-block'>Message</a></div></div>";
        return html;
    }

    public String createCard(string name, string branch, string email, string gender)
    {
        string html;
        if (gender.Equals("Male"))
        {
            html = "<div class='card people'><div class='card-top blue'><img src='images/silhouette_homer.png' alt='' /></div><div class='card-info'><a class='title' href='#'>" + name + "</a><div class='desc'>" + branch + "<br />" + email + "</div></div><div class='card-bottom'><a id=" + email + " class='btn btn-block'>Message</a></div></div>";
        }
        else
        {
            html = "<div class='card people'><div class='card-top green'><img src='images/silhouette_lisa.png' alt='' /></div><div class='card-info'><a class='title' href='#'>" + name + "</a><div class='desc'>" + branch + "<br />" + email + "</div></div><div class='card-bottom'><a id=" + email + " class='btn btn-block'>Message</a></div></div>";
        }

        return html;
    }
}